package com.sinosoft.dsp.platform.components.portal.iteration;

import java.util.List;
import java.util.Map;

import org.primefaces.event.NodeSelectEvent;
import org.primefaces.model.DefaultTreeNode;
import org.primefaces.model.TreeNode;

import com.sinosoft.dsp.platform.exception.SinoPlatformException;

/**
 * 树形ViewBean
 * 
 * @author 潘巍（PeterPan）
 * @since 2011-5-23 上午10:41:38
 * 
 * @param <T>
 */
public interface ISinoTreeViewBean<T extends ISinoTreeDataObject> extends
		IIterationViewBean<T> {
	// 默认的打开图标
	public static final String DEFAULT_EXPANDED_ICON = "ui-icon ui-icon-folder-open";

	// 默认的收起图标
	public static final String DEFAULT_COLLAPSED_ICON = "ui-icon ui-icon-folder-collapsed";

	// 默认的叶子节点图标
	public static final String DEFAULT_LEAF_ICON = "ui-icon ui-icon-document";

	public TreeNode getRootNode();

	public Map<String, DefaultTreeNode> getNodesMap();

	public void setNodesMap(Map<String, DefaultTreeNode> nodesMap);

	public DefaultTreeNode[] getSelectedNodes();

	public void setSelectedNodes(DefaultTreeNode[] selectedNodes);

	public DefaultTreeNode getSelectedNode();

	public void setSelectedNode(DefaultTreeNode selectedNode);
	
	public void addRootChild(DefaultTreeNode node);

	/**
	 * 通过ID获得树节点
	 * 
	 * @param id
	 * @return
	 */
	public DefaultTreeNode getNode(String id);

	/**
	 * 删除节点
	 * 
	 * @param n
	 * @throws SinoPlatformException
	 */
	public void delNode(DefaultTreeNode n) throws SinoPlatformException;

	/**
	 * 通过ID删除子节点
	 * 
	 * @param id
	 * @throws SinoPlatformException
	 */
	public void delNodeChildren(String id) throws SinoPlatformException;

	/**
	 * 删除子节点
	 * 
	 * @param n
	 * @throws SinoPlatformException
	 */
	public void delNodeChildren(DefaultTreeNode n) throws SinoPlatformException;

	/**
	 * 移动节点
	 * 
	 * @param targetId
	 * @param moveId
	 * @throws SinoPlatformException
	 */
	public void moveNode(String targetId, String moveId)
			throws SinoPlatformException;

	public String getDefaultExpandedIcon();

	public void setDefaultExpandedIcon(String defaultExpandedIcon);

	public String getDefaultCollapsedIcon();

	public void setDefaultCollapsedIcon(String defaultCollapsedIcon);

	public String getDefaultLeafIcon();

	public void setDefaultLeafIcon(String defaultLeafIcon);

	/**
	 * 获得树节点类型
	 * 
	 * @return
	 */
	public List<SinoTreeNodeType> getTreeNodeType();

	/**
	 * 添加树节点类型
	 * 
	 * @param nodeType
	 */
	public void addTreeNodeType(SinoTreeNodeType nodeType);

	/**
	 * 是否动态加载
	 * 
	 * @return
	 */
	public boolean isDynamic();

	/**
	 * 获得选择节点的类型
	 * 
	 * @return
	 */
	public String getSelectionMode();

	/**
	 * 设置选择节点的类型
	 * 
	 * @param selectionMode
	 */
	public void setSelectionMode(SinoTreeSelectNodeType selectionMode);

	/**
	 * 节点选择事件
	 * 
	 * @param event
	 */
	public void onNodeSelect(NodeSelectEvent event);

	/**
	 * 获得当前节点
	 * 
	 * @return
	 */
	public DefaultTreeNode getCurrentNode();

	/**
	 * 设置当前节点
	 * 
	 * @param node
	 */
	public void setCurrentNode(DefaultTreeNode node);

	/**
	 * 获得当前节点的子节点
	 * 
	 * @return
	 */
	public List<TreeNode> getCurrentNodeChildren();

	/**
	 * 改变当前节点
	 * 
	 * @param id
	 */
	public void changeCurrentNode(String id);
}
